package reesoft.common.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * 文件处理公共单元
 *
 * Created by reesoft on 2017-08-18
 */
public class FileUtil
{
    public static byte[] getFileContent(final String filePath)
    {
        File file = null;
        FileInputStream fileInputStream = null;

        try
        {
            file = new File(filePath);
            fileInputStream = new FileInputStream(file);

            byte[] content = new byte[(int)file.length()];

            if (fileInputStream.read(content) == content.length)
            {
                return content;
            }
        }
        catch (IOException e)
        {
        }
        finally
        {
            if (fileInputStream != null)
            {
                try
                {
                    fileInputStream.close();
                }
                catch (IOException e)
                {
                }
            }
        }

        return null;
    }
}
